<template>
  <div>
    <van-swipe class="my-swipe" indicator-color="white">
      <van-swipe-item v-for="(item, index) in options" :key="index">
        <img
          :src="item"
          style="width: 100%; height: 180px"
          @click="handleImg"
        />
      </van-swipe-item>
    </van-swipe>
  </div>
</template>

<script>
import { getCarouselConfig } from '../api/tbCarouselConfig'

export default {
  data() {
    return {
      options: [],
    }
  },
  props: {
    /**
     * 德治教化首页 1 综合服务首页 2 法治保障首页 3 政务公开首页 4
     **/
    carouselType: {
      type: String,
      default: '1',
    },
  },
  methods: {
    handleImg() {},
    async search() {
      let res = await getCarouselConfig({ carouselType: this.carouselType })
      if (res.data && res.data.length === 1) {
        this.options = res.data.map((i) => i.picUrlList.split(','))[0]
      } else if (res.data && res.data.length > 1) {
        this.options = res.data.map((item) => item.picUrlList)
      }
    },
  },
  mounted() {
    this.search()
  },
}
</script>
